package com.cnswhy.cloud.server.system.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.cnswhy.cloud.common.core.base.entity.Entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.cnswhy.cloud.common.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 用户操作日志表
 * </p>
 *
 * @author cnswhy
 * @since 2020-10-09
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("t_log")
@ApiModel(value = "Log", description = "用户操作日志表")
@AllArgsConstructor
public class Log extends Entity<Long> {

    private static final long serialVersionUID = 1L;

    /**
     * 操作用户
     */
    @ApiModelProperty(value = "操作用户")
    @Length(max = 50, message = "操作用户长度不能超过50")
    @TableField(value = "USERNAME", condition = LIKE)
    @Excel(name = "操作用户")
    private String username;

    /**
     * 操作内容
     */
    @ApiModelProperty(value = "操作内容")
    @Length(max = 65535, message = "操作内容长度不能超过65535")
    @TableField("OPERATION")
    @Excel(name = "操作内容")
    private String operation;

    /**
     * 耗时
     */
    @ApiModelProperty(value = "耗时")
    @TableField("TIME")
    @Excel(name = "耗时")
    private Long time;

    /**
     * 操作方法
     */
    @ApiModelProperty(value = "操作方法")
    @Length(max = 65535, message = "操作方法长度不能超过65535")
    @TableField("METHOD")
    @Excel(name = "操作方法")
    private String method;

    /**
     * 方法参数
     */
    @ApiModelProperty(value = "方法参数")
    @Length(max = 65535, message = "方法参数长度不能超过65535")
    @TableField("PARAMS")
    @Excel(name = "方法参数")
    private String params;

    /**
     * 操作者IP
     */
    @ApiModelProperty(value = "操作者IP")
    @Length(max = 64, message = "操作者IP长度不能超过64")
    @TableField(value = "IP", condition = LIKE)
    @Excel(name = "操作者IP")
    private String ip;

    /**
     * 操作地点
     */
    @ApiModelProperty(value = "操作地点")
    @Length(max = 50, message = "操作地点长度不能超过50")
    @TableField(value = "location", condition = LIKE)
    @Excel(name = "操作地点")
    private String location;


    @Builder
    public Log(Long id, LocalDateTime createTime, LocalDateTime updateTime, Long createUser, Long updateUser, 
                    String username, String operation, Long time, String method, String params,
                    String ip, String location) {
        this.id = id;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.createUser = createUser;
        this.updateUser = updateUser;
        this.username = username;
        this.operation = operation;
        this.time = time;
        this.method = method;
        this.params = params;
        this.ip = ip;
        this.location = location;
    }

}
